var arr = [
    {name:"可口可乐",price:2.3,sales:1000,grade:9.5},
    {name:"百事可乐",price:3,sales:900,grade:9.8},
    {name:"非常可乐",price:1.5,sales:750,grade:8.5},
    {name:"健力宝",price:5,sales:100,grade:9.6},
]
//设计一个函数，实现可以根据不同属性进行排序
function paixu(prop,orderBy){
    arr.sort(function(a,b){
        if(a[prop]>b[prop]){
            return orderBy;
        }else{
            return -orderBy;
        }
    })
}
paixu("grade",1);
console.log(arr);
